1. Field of the Invention
The invention relates to a method for browsing EJB entity beans by means of a Java servlet which is invoked by a service request from a browser including the name of an entity bean type and an entity bean key. The invention also relates to a corresponding apparatus and program product.
2. Description of the Related Art
In programming of Web applications the Java programming language is broadly employed. Such applications are distributed to the Web server site and to the customer client site. A preferred architectural approach in developing Web server applications is the use of the Java Servlet Architecture (Goodwill, xe2x80x98Developing JAVA Servletsxe2x80x99, Sams Publishingxe2x80x94SAMS/Macmillan Computer Publishing, Indianapolis, USA, 1999). A Java servlet is a dynamically loaded program module that extends the functionality of a server and receives requests from a client, performs processing steps to generate a response, possibly by querying databases, and sends the response to the client where the response may include an HTML or XML document. A Java servlet is object oriented and contains service methods according to the service functions of the servlet. A service method receives a servlet request object and a servlet response object. The servlet request object holds the information that the client provides to the servlet and the servlet response indicates where to place the data which has to be sent back to the client.
There exist two classes of servlets: generic servlets and HTTP specific servlets where the latter are an extension from GenericServlet. These classes implement the framework for all servlets which includes the init( ) method that initializes a servlet, the service( ) method that receives client requests and responds to them, and the destroy( ) method that performs cleanup.
Another technology available in the Java language is the Java Bean Architecture. Java beans are reusable software components that include a serializable interface and public get/set methods. A Java bean is characterized by the properties, events and methods which it contains and which it may export. Java beans may be used to support the development of applications.
The Java Bean Architecture comprises the Enterprise Java Bean Architecture which is a server-oriented technology for developing and deploying components containing business and transaction logic for enterprise applications (xe2x80x98Designing Enterprise Applications with the JAVA 2 Platform, Enterprise Editionxe2x80x99, Version 1.0, Sun Microsystems, Inc., Palo Alto, USA, March 2000). The Enterprise Java Beans (EJB) architecture applies the Java Beans concept to distributed business objects and provides a framework for extending the services provided by the Java beans technology with persistency, life cycle support, transactional behavior, remote services, etc. The EJB architecture comprises two types of enterprise beans: session beans and entity beans. A session bean provides services on behalf of a client and usually exists only for the duration of a single client-server session. An entity bean is a persistent object that represents data stored in a database or other persistent storage as long as that data is in existence. Each entity bean is identified by a primary key which can be used by a plurality of clients for finding the entity bean to retrieve its current content. For example, the primary key of an entity bean that represents a bank account may be the account number. The primary class key of this example is BankAccountKey, comprised of a property xe2x80x9cnumberxe2x80x9d.
In servlet-based Web applications there is currently no way to browse business objects represented by EJB entity beans in a generic way. This means that if someone wants to display the contents of entity beans, a customized servlet has to be developed that has to contain specific code for every entity bean class being accessed. A generic solution which can avoid the development of such specific code would have the advantage that a single reusable servlet can be used to browse through all kinds of entity beans.
It is an object of the invention to provide a possibility to browse business objects represented by EJB entity beans in a generic way.
In particular, it is an object of the invention to introduce a generic servlet that is able to browse all kinds of EJB entity beans.
It is a further object of the invention to use only one type of servlet to browse an a priori unknown set of entity beans.
According to the invention, as defined in the claims, a Java servlet initiates an EJB server to perform an access to a bean directory by using the parameters included in the service request from a client application. An EJB entity bean home is identified in the directory service of the Java Naming and Directory Interface (JNDI) by using the name of an entity bean type included in the service request, and an entity instance is found in the identified bean home according to the entity bean key also derivable in the service request. By means of the Java Bean Introspector the entity bean instance is introspected to retrieve information from the entity bean including the properties and description of the entity bean. The servlet generates a service response containing a representation according to the retrieved information.
It is one aspect of the invention that the Java servlet is a generic servlet which is used for different client applications and irrespectively of type and format of the bean information to be retrieved.
The invention allows one to avoid the development of customized applications or servlets which comprise specific code for the browsing and editing of different entity bean classes. Instead a single reusable servlet can be used to browse through all kinds of entity beans.